package com.aiyige.page.publish.selectcourse.model;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by zhuyakun on 2018/3/23.
 */

public class Course implements Parcelable {
    public static final int TYPE_MAJOR_COURSE = 1;
    public static final int TYPE_TRAING_CLASS = 2;
    int type;
    String title;
    String id;
    boolean selected;
    String singlePrice;
    boolean singlePriceEditable;
    String totalPrice;
    String courseNum;

    public Course() {
    }

    private Course(Builder builder) {
        setType(builder.type);
        setTitle(builder.title);
        setId(builder.id);
        setSelected(builder.selected);
        setSinglePrice(builder.singlePrice);
        setSinglePriceEditable(builder.singlePriceEditable);
        setTotalPrice(builder.totalPrice);
        setCourseNum(builder.courseNum);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    public String getSinglePrice() {
        return singlePrice;
    }

    public void setSinglePrice(String singlePrice) {
        this.singlePrice = singlePrice;
    }

    public boolean isSinglePriceEditable() {
        return singlePriceEditable;
    }

    public void setSinglePriceEditable(boolean singlePriceEditable) {
        this.singlePriceEditable = singlePriceEditable;
    }

    public String getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(String totalPrice) {
        this.totalPrice = totalPrice;
    }

    public String getCourseNum() {
        return courseNum;
    }

    public void setCourseNum(String courseNum) {
        this.courseNum = courseNum;
    }

    public static final class Builder {
        private int type;
        private String title;
        private String id;
        private boolean selected;
        private String singlePrice;
        private boolean singlePriceEditable;
        private String totalPrice;
        private String courseNum;

        private Builder() {
            title = "";
            id = "";
            selected = false;
            type = 0;
            singlePrice = null;
            singlePriceEditable = true;
            totalPrice = "";
            courseNum = "";
        }

        public Builder type(int type) {
            this.type = type;
            return this;
        }

        public Builder title(String title) {
            this.title = title;
            return this;
        }

        public Builder id(String id) {
            this.id = id;
            return this;
        }

        public Builder selected(boolean selected) {
            this.selected = selected;
            return this;
        }

        public Builder singlePrice(String singlePrice) {
            this.singlePrice = singlePrice;
            return this;
        }

        public Builder singlePriceEditable(boolean singlePriceEditable) {
            this.singlePriceEditable = singlePriceEditable;
            return this;
        }

        public Builder totalPrice(String totalPrice) {
            this.totalPrice = totalPrice;
            return this;
        }

        public Builder courseNum(String courseNum) {
            this.courseNum = courseNum;
            return this;
        }

        public Course build() {
            return new Course(this);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.type);
        dest.writeString(this.title);
        dest.writeString(this.id);
        dest.writeByte(this.selected ? (byte) 1 : (byte) 0);
        dest.writeString(this.singlePrice);
        dest.writeByte(this.singlePriceEditable ? (byte) 1 : (byte) 0);
        dest.writeString(this.totalPrice);
        dest.writeString(this.courseNum);
    }

    protected Course(Parcel in) {
        this.type = in.readInt();
        this.title = in.readString();
        this.id = in.readString();
        this.selected = in.readByte() != 0;
        this.singlePrice = in.readString();
        this.singlePriceEditable = in.readByte() != 0;
        this.totalPrice = in.readString();
        this.courseNum = in.readString();
    }

    public static final Creator<Course> CREATOR = new Creator<Course>() {
        @Override
        public Course createFromParcel(Parcel source) {
            return new Course(source);
        }

        @Override
        public Course[] newArray(int size) {
            return new Course[size];
        }
    };
}
